import Vue from 'vue'

const mutations = {
  SET_DATA_MAP(state, { key, data }) {
    Vue.set(state.dataMap, key, data) // 使用Vue.set确保响应性
  }
}

const actions = {}

const getDefaultState = () => {
  return {
    options: undefined,
    dataMap: {}
  }
}

const state = getDefaultState()

const getters = {
  dataByKey: (state) => (key) => {
    return state.dataMap[key] || undefined;
  }
}

export default {
  namespaced: true,
  getters,
  state,
  mutations,
  actions
}

